import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { AllResponseInterceptor } from './all-response/all-response.interface';
import { AllExceptionFilter } from './all-exception/all-exception.filter';
import { NestExpressApplication } from '@nestjs/platform-express';

async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule);
  app.enableCors({ origin: true, credentials: true });
  app.useStaticAssets('./public');
  const config = new DocumentBuilder()
    .setTitle('接口') //标题
    .setDescription('安保系统服务端API接口') //描述
    .setVersion('1.0')
    .build();
  const document = SwaggerModule.createDocument(app, config);
  SwaggerModule.setup('cvnert', app, document); // localhost:3000/cvnert 访问接口文档
  app.useGlobalInterceptors(new AllResponseInterceptor());
  app.useGlobalFilters(new AllExceptionFilter());
  await app.listen(3000);
}
bootstrap();
